<?php
	$id_client = $_GET['id_client'];

	require_once('paths.inc');
	require_once('page.inc');
	
	require_once('page.inc');
	require_once(INCLUDE_PATH.'constants.inc');
	require_once('utils.inc');
	require_once(DB_PATH.'db.inc');	
    
    session_start();

	select_js_language();
	select_language();
	
	$ret =  "<div id=\"avansat\" align=\"center\">";
	
	$ret .=	'
				<table name="cautare_avansata" border="0" align="center" id="wrapper2">
					<thead>
						<th colspan="7" align="center">' . LANG_Cautare_avansata . '</th>
					</thead>
					<tr class="capTabel">
						<td align="left"><b>' . LANG_Data_scadenta_sol . '</b></td>' . 
						'<td colspan="3">' . 
	                        LANG_intre . " " .  
                            render_date_field_button('', 'data_scadenta_sol', 'DHTMLSuite_modalBox_contentDiv') . " " . 
                            LANG_si . " " . render_date_field_button('', 'data_scadenta_sol22', 'DHTMLSuite_modalBox_contentDiv') . '</td>' . 
               		        '<td><b>' . LANG_Data_scadenta_exec . '</b></td>' .
                            '<td colspan="3">' . 
               		        LANG_intre . " " .  
                            render_date_field_button('', 'data_scadenta_exec', 'DHTMLSuite_modalBox_contentDiv') . " " .
                            LANG_si . " " .                                 
                            render_date_field_button('', 'data_scadenta_exec22', 'DHTMLSuite_modalBox_contentDiv') . '
						</td>						
					</tr>
					<tr class="capTabel">
						<td align="left"><b>' . LANG_Data_factura_sol . '</b></td>' .
                            '<td colspan="3">' . 
	                        LANG_intre . " " .                              
                            render_date_field_button('', 'data_factura_sol', 'DHTMLSuite_modalBox_contentDiv') .
                            LANG_si . " " . render_date_field_button('', 'data_factura_sol22', 'DHTMLSuite_modalBox_contentDiv') . '</td>' . 
                            '<td><b>' . LANG_Data_factura_exec . '</b></td>' .
                            '<td colspan="3">' .  
                            LANG_intre . " " . 
                            render_date_field_button('', 'data_factura_exec', 'DHTMLSuite_modalBox_contentDiv') . ' ' .  
                            LANG_si . " " .                                                             
                            render_date_field_button('', 'data_factura_exec22', 'DHTMLSuite_modalBox_contentDiv') . "                        
						</td>						
					</tr>
					<tr class=\"capTabel\">
						<td align=\"left\"><b>" . LANG_Comanda_incasata . "</b></td>
						<td align=\"left\"><b>" . LANG_Comanda_platita . "</b></td>
						<td align=\"left\"><b>" . LANG_Scadenta_incasare_sapt . "</b></td>
						<td align=\"left\"><b>" . LANG_Scadenta_plata_sapt . "</b></td>
						<td align=\"left\"><b>" . LANG_Firma_solicitant . "</b></td>
						<td></td>
						<td align=\"left\"><b>" . LANG_Firma_executant . "</b></td>
					</td>				
					<tr class=\"capTabel\">
						<td align=\"left\">
							<select name=\"incasata2\" id=\"incasata2\">
						 		<option value=\"-1\"> --- </option>
						 		<option value=\"" . CT_COMANDA_INCASATA ."\">" . LANG_Da . "</option>
						 		<option value=\"" . CT_COMANDA_NEINCASATA ."\">" . LANG_Nu . "</option> 
						 		<option value=\"" . CT_COMANDA_INCASATA_PARTIAL ."\">" . LANG_Partial . "</option>
					 		</select>
				 		</td>
				 		<td align=\"left\">
							<select name=\"platita2\" id=\"platita2\">
						 		<option value=\"-1\"> --- </option>
							 	<option value=\"" . CT_COMANDA_PLATITA ."\">" . LANG_Da . "</option>
							 	<option value=\"" . CT_COMANDA_NEPLATITA ."\">" . LANG_Nu . "</option>
							 	<option value=\"" . CT_COMANDA_PLATITA_PARTIAL ."\">" . LANG_Partial . "</option>
						 	</select>
					 	</td>
						<td align=\"left\">
							<select name=\"sc_incasare2\" id=\"sc_incasare2\">
								<option value=\"-1\"> --- </option>
								<option value=\"1\">1 " . LANG_saptamana . "</option>
								<option value=\"2\">2 " . LANG_saptamani . "</option>
								<option value=\"3\">3 " . LANG_saptamani . "</option>
								<option value=\"4\">4 " . LANG_saptamani . "</option>
							</select>
						</td>
						<td align=\"left\">
							<select name=\"sc_plata2\" id=\"sc_plata2\">
								<option value=\"-1\"> --- </option>
								<option value=\"1\">1 " . LANG_saptamana . "</option>
								<option value=\"2\">2 " . LANG_saptamani . "</option>
								<option value=\"3\">3 " . LANG_saptamani . "</option>
								<option value=\"4\">4 " . LANG_saptamani . "</option>
							</select>
						</td>
						<td align=\"left\">
							<select name=\"f_sol2\" id=\"f_sol2\">
								<option value=\"-1\"> --- </option>";
								$firme = array();								
								$db = db_connect();
								$firme = Firma::queryLoadByClient($db, $id_client);
								$total = count($firme);
								for ($i = 0; $i < $total; $i++) {
									$ret .= "<option value=\"" . $firme[$i]->id_firma . "\">" . $firme[$i]->nume . "</option>";
								}			
							$ret .= "</select>				
						</td>
						<td align=\"left\">
							<select name=\"sau_si2\" id=\"sau_si2\">
								<option value=\"-1\"> --- </option>								
								<option value=\"OR\">" . LANG_OR . "</option>
								<option value=\"AND\">" . LANG_AND . "</option>
							</select>
						</td>
						<td align=\"left\">
							<select name=\"f_exec2\" id=\"f_exec2\">
								<option value=\"-1\"> --- </option>";
									for ($i = 0; $i < $total; $i++) {
										$ret .= "<option value=\"" . $firme[$i]->id_firma . "\">" . $firme[$i]->nume . "</option>";
									}			
							$ret .= "</select>
						</td>						
					</tr>	
					<tr class=\"capTabel\">
						<td colspan=\"7\" align=\"left\"><b>" . LANG_pret . "</b> " . 
						LANG_intre . " " . 
						"<input size=\"5\" type=\"text\" value=\"\" name=\"pret1\" id=\"pret1\" /> " .
						LANG_si . " " . 
						"<input size=\"5\" type=\"text\" value=\"\" name=\"pret2\" id=\"pret2\" /> " .   
						"<b>" . LANG_cost . "</b> " . 
						LANG_intre . " " . 
						"<input size=\"5\" type=\"text\" value=\"\" name=\"cost1\" id=\"cost1\" /> " .
						LANG_si . " " . 
						"<input size=\"5\" type=\"text\" value=\"\" name=\"cost2\" id=\"cost2\" />  
						</td>						
					</tr>	
					<tr class=\"capTabel\">
						<td colspan=\"7\" align=\"left\"><b>" . LANG_Search . "</b>
							<span id=\"campuri2\">
								<input type=\"text\" id=\"keyword2\" name=\"keyword2\" value=\"\" onkeypress=\"onEnter(event, 'cauta_comanda_avansata')\" />
							</span>" . LANG_in . "  						
							<select name=\"camp2\" id=\"camp2\" onchange=\"javascript: modifica_camp(this.value, 'cautare_avansata');\">
								<optgroup label=\"" . LANG_Campuri_comanda . "\" value=\"text\" />
		                        <option value=\"-1\">" . LANG_All . "</option>
								<option value=\"nr_comanda_sol\">" . LANG_Nr_comanda_sol . "</option>
								<option value=\"nr_comanda_exec\">" . LANG_Nr_comanda_exec . "</option>
								<option value=\"nr_factura_sol\">" . LANG_nr_factura_sol . "</option>
								<option value=\"nr_factura_exec\">" . LANG_nr_factura_exec . "</option>
								<option value=\"nume_sofer\">" . LANG_Nume_sofer . "</option>
								<option value=\"tel_sofer\">" . LANG_tel_sofer . "</option>
								<option value=\"nr_inmatriculare\">" . LANG_nr_inmatriculare . "</option>
								<option value=\"fel_camion\">" . LANG_Fel_camion . "</option>
								<option value=\"fel_marfa\">" . LANG_Fel_marfa . "</option>
								<option value=\"1tonaj\">" . LANG_Tonaj . "</option>								
								<optgroup label=\"" . LANG_DATE_COMANDA . "\" value=\"text\" />
								<option value=\"1data_scadenta_sol\">" . LANG_Data_scadenta_sol . "</option>
								<option value=\"1data_scadenta_exec\">" . LANG_Data_scadenta_exec . "</option>						
								<option value=\"1data_factura_sol\">" . LANG_Data_factura_sol . "</option>											
								<option value=\"1data_factura_exec\">" . LANG_Data_factura_exec . "</option>								
							</select>																		
						</td>
					</tr>" . 
					'<tr class="capTabel">
						<td colspan="7" align="center">';
							$ret .= buton_final_modal_ok(LANG_Cauta, "contact_confirm", "new_cauta_confirm()") . '&nbsp;&nbsp;';
							$ret .= buton_final_modal_cancel(LANG_Cancel, "close_cautare_avansata()") . '
						</td>
					</tr>'
                    . output_extra_text_modal(LANG_EXTRA_CAUTARE_AVANSATA_COMENZI, 7) . 
				'</table>
			<script type="text/javascript">
				document.contact_nume.focus();
			</script>';
	$ret .= "</div>";
	echo $ret;
?>